<? include ("../init.php") ?>
<? include ("../header.php") ?>
<? include ("../menu.php") ?>
<? include ("submenu.php") ?>
<?php
  function get_project_catname($cat_id){
    $db2 = new DB(DB_NAME, DB_SERVER, DB_USER, DB_PWD);
    $db2->charset(DB_CHARSET);
    $sql = 'SELECT * FROM project_cat WHERE project_cat_id='.$cat_id;
    $line = $db2->queryUniqueObject($sql);
    $db2->close();
    return $line->project_cat_name;
  }
?>
<div id = "body">

<h1><?_l('project')?></h1>

<a href = "form2.php" class = "add"><img src = "<?=ADMIN?>/images/icon-add.png">&nbsp;&nbsp;&nbsp;<?_l('add-project')?></a>

<div class = "clear"></div>

<div class = "page">
<?
  $count = $db->countOfAll('projects');
  $start = setpage($count);
?>
</div>

<div class = "clear"></div>

<table class ="list">
  <tr>
    <th scope="col"><?_l('name')?></th>
    <th scope="col"><?_l('catalogue')?></th>
    <th scope="col" width = "50"><?_l('edit')?></th>
    <th scope="col" width = "50"><?_l('delete')?></th>
  </tr>
<?
  $rss = $db->query("SELECT * FROM projects ORDER BY project_title LIMIT $start,".PAGE);
  while ($line = $db->fetchNextObject($rss)){
?>
  <tr>
    <td><?=$line->project_title?></td>
    <td><?=get_project_catname($line->project_cat_id)?></td>
    <td><a href = "edit.php?aid=<?=$line->project_id?>" class = "btn"><?_l('edit')?></a></td>
    <td><a href = "del2.php?aid=<?=$line->project_id?>" class = "btn" onClick = "return confirmSubmit()"><?_l('delete')?></a></td>
  </tr>
<?
  }
?>
</table>

</div>

<style>

</style>

<? include "../footer.php" ?>